﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;

namespace HomeWork
{
    class HelpMoney : Entity<int>
    {
        public Content Content { get; set; } //父类                                 
        public User Owner { get; set; } //账户所有者
        public  int EnableAmount { get; set; } = 1000;  //可用金额
        public int DisableAmount { get; set; } //冻结金额
        public int Vary { get; set; } //变动金额        
        public String Remark { get; set; } //备注
        public String Kind { get; set; } //类型
        DateTime Now = DateTime.Now;   //当前时间

        public HelpMoney(int id) : base(id)
        {

        }

        public HelpMoney()
        {

        }

        public void Decrease()//根据不同类型消耗帮帮币
        {
            if (Content is Article)
            {
                EnableAmount--; //减少一枚帮帮币
                Owner.Bmoney = EnableAmount; //用户余额
            }
            else if (Content is Problem)
            {
                AccountFrozen(); //冻结金额
                Owner.Bmoney=EnableAmount; //用户余额
               
            }//else nothing
        }
              
                        

        public void AccountFrozen() //冻结金额后的剩余金额，同时填写变化金额
        {            
            EnableAmount -= DisableAmount;
            Vary = DisableAmount; 

        }

        public void TradRecord() 
        {
            Console.WriteLine("于" + Now + "进行了" + Kind + "操作，金额" + Vary + "备注：" + Remark);
            Console.WriteLine("目前可用金额:" + EnableAmount + "冻结金额:" + DisableAmount);
        }
    }
}
